<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>自动跳转</title>
		<style type="text/css">
			*{
				text-align: center;
			}
			
			#sec{
				color: red;
				font-size: 25px;
			}
		</style>
	</head>
	<body>
		<h1>提交成功</h1>
		<a href="http://www.runoob.com/">
			<span id="sec">5</span>秒后系统自动跳转，也可以单击此链接跳转
		</a>
		<script>
			/*1、数字递减
			 2、单数字到0时，跳转到某个URL*/
			var number=5;
			var span=document.getElementById('sec');
			function q(){
				if(number>0){
					number--;
					span.innerHTML=number;
				}else{
					clearInterval(timer);
					location.href="http://www.runoob.com/";
				}
			}
			var timer=window.setInterval(q,1000);
		</script>
	</body>
</html>
